/*
** my_read.c for my_read in /home/lingla_j//work/projets/minishell/3
** 
** Made by julien linglain
** Login   <lingla_j@epitech.net>
** 
** Started on  Thu Dec 29 11:27:22 2011 julien linglain
** Last update Fri Mar 30 15:37:13 2012 julien linglain
*/

#include <unistd.h>
#include <stdlib.h>
#include "mysh.h"

char	*my_read()
{
  int	i;
  int	lenread;
  char	*bufread;
  char	*bufres;

  i = 0;
  bufres = xmalloc(sizeof(*bufres) * 256);
  bufread = xmalloc(sizeof(*bufread) * 256);
  lenread = xread(0, bufread, 255);
  while (i < lenread && bufread[i] != '\n')
    {
      bufres[i] = bufread[i];
      i = i + 1;
    }
  bufres[i] = '\0';
  if (lenread == 1)
    return (NULL);
  return (bufres);
}
